<template>
  <div class="pro">
    <img v-lazy="pro.thumb_url" class="pro_img" />
    <div class="pro_text">
      <p class="all">
        <em>{{ pro.price | moneyFormat }}</em>
      </p>
      <p class="all">{{ pro.short_name }}</p>
      <p class="all">医药商城自营店</p>
    </div>
    <div class="add_btn">
      <a @click="goDetail(pro.goods_id)"><el-button type="danger">查看详情</el-button></a>
    </div>
  </div>
</template>

<script>
export default {
  props: {
    pro: {
      type: Object,
      required: true,
    },
  },
  methods: {
    goDetail(id) {
      this.$router.replace("/goods/" + id);
    },
  },
};
</script>

<style scoped>
.pro {
  margin: 20px;
  padding: 20px;
  width: 100%;
  max-width: 300px;
  background: white;
  border: 1px solid #eee;
  border-radius: 10px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);

  display: flex;
  flex-direction: column;
  align-items: center;
}

.pro_img {
  width: 120px;
  height: 120px;
  border-radius: 10px;
}

.pro_text {
  margin-top: 10px;
  width: 100%;
  text-align: center;
  line-height: 1.5;
}

.pro_text>p:first-child {
  color: red;
  font-weight: 900;
  font-size: 18px;
}

.pro_text>p:nth-child(2) {
  font-size: 14px;
}

.pro_text>p:nth-child(3) {
  font-size: 12px;
  color: #999;
}

.add_btn {
  margin-top: 10px;
  width: 100%;
  display: flex;
  justify-content: center;
}

.add_btn>a>.el-button {
  width: 100%;
  max-width: 120px;
  height: 35px;
}

.all {
  margin: 0;
}

@media (max-width: 768px) {
  .pro {
    max-width: 100%;
  }

  .pro_img {
    width: 100px;
    height: 100px;
  }

  .pro_text>p:first-child {
    font-size: 16px;
  }

  .pro_text>p:nth-child(2) {
    font-size: 12px;
  }

  .pro_text>p:nth-child(3) {
    font-size: 11px;
  }

  .add_btn>a>.el-button {
    max-width: 100px;
    height: 30px;
  }
}

@media (max-width: 480px) {
  .pro {
    margin: 10px;
    padding: 15px;
  }

  .pro_img {
    width: 80px;
    height: 80px;
  }

  .pro_text>p:first-child {
    font-size: 14px;
  }

  .pro_text>p:nth-child(2) {
    font-size: 11px;
  }

  .pro_text>p:nth-child(3) {
    font-size: 10px;
  }

  .add_btn>a>.el-button {
    max-width: 90px;
    height: 28px;
  }
}
</style>
